package com.example.springdemo6.controller;

import com.example.springdemo6.Model.Message;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/message")
public class MessageController {

    private List<Message> list = new ArrayList<>();
    //提交留言
    @RequestMapping("/submit")
    public boolean submitMessage(Message message) {
        if(!StringUtils.hasLength(message.getFrom()) || !StringUtils.hasLength(message.getInfo())
                || !StringUtils.hasLength(message.getTo())) {
            return false;
        }
        list.add(message);
        return true;
    }
    @RequestMapping("/getMessage")
    public List<Message> getMessage() {
        return list;
    }
}
